{extend name="public/base" /}
{block name="title"}广告位管理{/block} {block name="main"}
<blockquote class="layui-elem-quote quoteBox e-quoteBox">
    <form class="layui-form" action="" method="GET">        
        <div class="layui-inline">
            <label class="layui-form-label">所属平台</label>
            <div class="layui-input-inline layui-col-md6">
            <select name="plat">
                <option value="">全部平台</option>
                <option value="2" {$where['plat'] == 2  ? 'selected': ''} >平台广告</option>
                <option value="3" {$where['plat'] == 3  ? 'selected': ''}>站点广告</option>
            </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">所属渠道</label>
            <div class="layui-input-inline layui-col-md6">
                <select name="channel">
                    <option value="">全部渠道</option>
                    {volist name="$channelList" id="item"}
                    <option value="{$key}" {$key == $where['channel'] ? 'selected': ''}>{$item}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-inline layui-col-md6">
                <select name="status">
                    <option value=""  {$where['status']==''? 'selected': ''}>全部</option>
                    <option value="1" {$where['status']==1? 'selected': ''}>正常</option>
                    <option value="2" {$where['status']==2? 'selected': ''}>关闭</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">关键字</label>
            <div class="layui-input-inline layui-col-md6">
                <input type="text" name="keyword" value="{$where['keyword']}" class="layui-input searchVal" placeholder="请输入搜索的内容" />
            </div>
        </div>
        <div class="layui-inline">
        <button class="layui-btn search_btn" id="savebtn" lay-submit="">搜索</button>
        <a href="/set/adposition/add" class="layui-btn layui-btn-normal addNews_btn">添加广告位</a>
        </div>
    </form>
</blockquote>
<form class="layui-form">
    <table cellspacing="0" cellpadding="0" border="0" style="width: 100%;" class="layui-table">
        <thead>
            <tr>
                <th>ID</th>
                <th>名称</th>
                <th>标识</th>
                <th>尺寸px</th>
                <th>所属平台</th>
                <th>展示渠道</th>
                <th style="width: 80px;">状态</th>
                <th class="layui-table-fixed layui-table-fixed-r">操作</th>
            </tr>
        </thead>
        <tbody>
            {if condition="$data['msg']"}
                <tr class="td_center"><td colspan="10">{$data['msg']}</td></tr>
            {/if}
            {volist name="data['list']" id="item"}
            <tr class="nodelist depth01">
                <td class="td_left">
                    <div class="layui-table-cell ">{$item['id']}</div>
                </td>
                <td class="td_left">
                    <div class="layui-table-cell ">{$item['name']}</div>
                </td>
                <td class="td_left">
                    <div class="layui-table-cell ">{$item['tag']}</div>
                </td>
                <td class="td_left">
                    <div class="layui-table-cell ">宽{$item['width']} * 高{$item['height']}</div>
                </td>
                <td class="td_left">
                    <div class="layui-table-cell ">
                        {$item['plat'] == 2 ? '平台广告位':''}
                        {$item['plat'] == 3 ? '站点广告位':''}
                    </div>
                </td>
                <td class="td_left">
                    <div class="layui-table-cell ">{$channelList[$item['channel']]}</div>
                </td>
                <td class="td_left">
                    <div class="layui-table-cell layui-inline" style="height:auto;">
                        <input lay-filter="status" type="checkbox" {$item[ 'status']==1? 'checked': ''} data-id="{$item['id']}" lay-skin="switch" lay-text="正常|关闭">
                    </div>
                </td>
                <td class="td_center">
                    <div class="layui-btn-group">
                    <a href="/set/adposition/edit/id/{$item['id']}" class="layui-btn layui-btn-sm">编辑</a>
                    {if condition="$item['plat'] eq 2"}
                    <a href="/set/ad/index/pid/{$item['id']}" class="layui-btn layui-btn-normal layui-btn-sm">广告管理</a>
                    {/if}
                    </div>
                </td>
            </tr>
            {/volist}
        </tbody>
    </table>
</form>
{$showpage|raw} 

{/block} {block name="script"}
<script>
    layui.use(['form'], function (form) {
        form.on('switch(status)', function (data) {
            var id = $(data.elem).data("id");
            var ischecked = data.elem.checked;
            $.post("/set/adposition/editstatus",{id:id},function(ret){
                if(ret.code!=1){
                    layer.msg(ret.msg);
                    if(ischecked){
                        $(data.elem).prop("checked",false);
                        $(data.othis).removeClass("layui-form-onswitch").find("em").text("关闭");
                    }else{
                        $(data.elem).prop("checked",true);
                        $(data.othis).addClass("layui-form-onswitch").find("em").text("正常");
                    }
                }
            })
            return false;
        });
    });
</script> {/block}